import {createBrowserRouter,Navigate} from 'react-router-dom'
import Login from '../pages/login'
import Home from '../pages/home'
import { lazy } from 'react'
import HOC from './HOC'

const Pages1 = lazy(() => import('../pages/home/pages1'))
const Pages2 = lazy(() => import('../pages/home/pages2'))

//创建history的路由模式
const router=createBrowserRouter([
    {
        path:'/',
        element:<Navigate to='/login'/>
    },
    {
        path:'/login',
        element:<Login/>
    },
    {
        path:'/home',
        element:<Home/>,
        children:[
            {
                path: '',
                element: <Navigate to='/home/pages1' />
            },
            {
                path:'pages1',
                element:HOC(<Pages1/>)
            },
            {
                path:'pages2',
                element:HOC(<Pages2/>)
            },
            
        ]
    },
    {
        path:'*',
        element:<h1>404 not Found</h1>
    }
])
export default router;